/**********************************************************************************************************
*	© 2010 Autodata Solutions Company. All Rights Reserved
*	This source code is the confidential and proprietary information of Autodata Solutions Company.
*	The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code 
*	without the prior written consent of Autodata Solutions Company.
*
*	Author(s)	: Chris Raposo
*	Purpose		: Add page functionality for compare editorial
* 	Version		: 1.0
*********************************************************************************************************/

(function() {
    var EVENTS = net.autodata.EventBus.EVENTS;
    
    Ext.onReady(function() {
        var session = net.autodata.Session.getInstance();
        var eb = net.autodata.EventBus.getInstance();

        var ptb = new net.autodata.compare.toolbars.PageToolbar({
            viewCfg: {
                activeKey: 'editorial'
            },
            renderTo: 'comparetoppanel-wrap'
        });
        
        var cvp = new net.autodata.compare.CompareVehiclesPanel({
            plugins: [
		        new net.autodata.compare.plugins.CompareVehiclesEventBus(),
		        new net.autodata.compare.plugins.CompareVehiclesNavigation(),
			    new net.autodata.compare.plugins.CompareVehiclesColourPicker()
	        ],

            renderTo: 'comparevehiclepanel-wrap',

            storeCfg: {
                proxy: new net.autodata.compare.data.CompareVehiclesSessionProxy()
            },

            view: new net.autodata.compare.CompareVehiclesView()
        });

        var ds = net.autodata.modelwalk.data.YearMakeModelDataStore.getInstance();
        ds.load();

        var toolbar = new net.autodata.compare.CompetitorToolbar({
            view: new net.autodata.compare.EditorialToolbarView(),
            storeCfg: {
                proxy: new net.autodata.compare.data.CompareVehiclesSessionProxy()
            },
            plugins: [
                new net.autodata.compare.plugins.CompetitorToolbarEventBusConnector()
            ]
        });

        var ep = new net.autodata.compare.editorial.EditorialPanel({
            tbar: toolbar,
            title: ASC.message('net.autodata.compare.editorial.panel.title.text'),
            readmore: ASC.message('net.autodata.compare.editorial.panel.readmore'),
            emptyText: ASC.message('net.autodata.compare.editorial.panel.empty-text'),
            storeCfg: {
                proxy: new net.autodata.compare.data.EditorialHttpCacheProxy()
            },
            plugins: [
                toolbar,
                new net.autodata.compare.editorial.plugins.EditorialPanelEventBusConnector(),
                new net.autodata.compare.plugins.CompetitorToolbarPanelConnector({ toolbar: toolbar })
            ],
            renderTo: 'comparebottompanel-wrap'
        });

        eb.fireEvent(EVENTS.READY);
    });
})();